package com.kk.model.result.exception;

import com.kk.model.result.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;


/**
 * the class of springboot-prototype-global-exception
 *
 * <p>
 * .
 *
 * @author little_lunatic
 * @date 2023-02-08
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Component
public class MyException extends Throwable implements ResultCode {

    private static final long serialVersionUID = 194906846739586856L;

    /**
     * 状态码
     */
    private String code;

    /**
     * 错误信息，给开发人员看的，前端不展示
     */
    private String msg;

    public MyException(ResultCode resultCode){
        this.code = resultCode.code();
        this.msg = resultCode.msg();
    }

    @Override
    public String code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }
}
